/*=====================================================
 Copyright (C) ETERNAL<iqstar@ms24.hinet.net>
 URL : http://www.et99.net

请仔细阅读以下许可协议。当您使用本软体，您将自动成为本协议的一方并受到本协议的约束。

软体和文档受到台湾及中国大陆著作权法及国际条约的保护。您不得：
a)营利、出租或者出借软体或文档的任何部分。
b)反向工程、分解、反编译或者企图察看软体的源代码作为商业用途。
c)修改或者改变软体，或者与其他程式结合。

许可人保留软体及文档的所有权利和权益。您不能通过本许可协定获得软体的任何所有权和知识产权。
===================================================== */

//###### 分页 begin #####
function pagesplit(saletotal, page, type) {
    // edit at 2022-06-07
    var limit_count = 100;
    var temp_html = "";
    temp_html += page_table1 + '<tr><td>分页:';
    var totalpage = 0;
    if (saletotal % limit_count == 0) {
        totalpage = saletotal / limit_count;
    } else {
        totalpage = (saletotal / limit_count) + 1;
    }
    for (var i = 1; i <= totalpage; i++) {
        if (i == page) {
            temp_html += ' ' + i + ' ';
        } else {
            temp_html += ' <a href="javascript:parent.page_jump(\'' + i + '\')" >' + i + '</a> ';
        }
    }
    temp_html += '</td></tr>' + temp_table2;
    if (type == null) {
        w_c(temp_html);
    } else {
        return temp_html;
    }
};

function page_jump(s) {
    parent.wog_view.document.pageform.page.value = s;
    parent.wog_view.document.pageform.submit();
};

function sel_type(s) {
    var fp = parent.wog_view.document.pageform;
    if (fp.key != null) {
        fp.key.value = '';
    }
    fp.type.value = s;
    fp.submit();
};

function system_view(s1, s2, type) {
    if (type != null) {
        w_c(temp_table1 + group_menu + temp_table2);
        w_c(hr);
    }
    w_c(temp_table1);
    w_c('<tr class="head_td"><td>内容</td><td>发生时间</td></tr>');
    if (s1 != "") {
        var a1 = s1.split(";");
        var a2 = s2.split(";");
        for (var i = 0; i < a1.length; i++) {
            w_c('<tr><td class=b1>' + a1[i] + '</td><td>' + a2[i] + '</td></tr>');
        }
    } else {
        w_c('<tr><td colspan="8" >尚未发生任何事件</td></tr>');
    }
    w_c(temp_table2);
    p_c();
};

/**
 * PK设定
 * @param s
 * @param money
 */
function pk_view(s, money) {
    if (s == 1) {
        var pk_yes = "checked";
        var pk_no = "";
    } else {
        var pk_yes = "";
        var pk_no = "checked";
    }
    w_c(`
    <div id="" class="pk-setting box-info-bg">
    <div class="font-size-16 text-gold text-center">PK设置</div>
    <input type="hidden" name="f" value="pk"><input type="hidden" name="act" value="setup">
    <p>PK：
    <label> <input type="radio" name="pk_setup" value="1" ${pk_yes}>接受</label>
    <label > <input type="radio" name="pk_setup" value="0" ${pk_no}>拒绝</label></p>
    <p>PK金额：<input type="text" name="pk_money" value="${money}" class="game-input" maxlength="6"><span class="text-grey ml-10">挑战我需要支付的金额</span></p>
    <p>PK金额设定最高999,999最低1,000,身上现金低于最低金额不能参加PK,系统会自动设定不参加PK赛</p>
    <p><button type="submit">确定</button> <button onclick="document.getElementById('wog_select').innerHTML=''" type="button">关闭</button></p>
</div>
    `);
    p_as();
};

function id_admin(a1, a2) {
    var te = "document.f1";
    w_c('<form action="wog_act.php" method="post" target="mission" name="f1">');
    w_c(left_table1);
    w_c('<tr class="head_td"><td>帐号</td><td>密码</td><td>操作</td></tr>');
    w_c('<tr><td><input type="text" size="12" maxlength="12" name="id"></td><td ><input type="password" size="12" name="password"></td><td><input type="submit" value="角色自杀" onclick="' + te + '.f.value=\'chara\';' + te + '.act.value=\'kill\';"></td></tr>');
    w_c('<tr class="head_td"><td>新密码</td><td>旧密码</td><td>操作</td></tr>');
    w_c('<tr><td><input type="text" size="12" maxlength="12" name="new_pw"></td><td ><input type="password" size="12" name="old_pw"></td><td><input type="submit" value="改变密码" onclick="' + te + '.f.value=\'chara\';' + te + '.act.value=\'chpw\';"></td></tr>');
    w_c('<tr class="head_td"><td colspan="3">其他</td></tr>');
    w_c('<tr><td colspan="3" >补发密码 <input type="text" size="25"  name="email"> (请输入您创立角色的EMAIL) <input type="button" value="送出" onclick="document.f3.email.value=' + te + '.email.value;document.f3.submit();"></td></tr>');
    w_c('<tr><td colspan="3" >更改帐号名称 <input type="text" size="20"  name="p_name"> (请输入新名称,此功能需消耗6点数) <input type="submit" value="送出" onclick="' + te + '.f.value=\'mall\';' + te + '.act.value=\'chgid\';"></td></tr>');
    w_c('<tr><td colspan="3"><input type="checkbox" onclick="parent.set_well_box()" ' + return_well_box() + '>不再显示友善消息</td></tr>');
    ;
    w_c(temp_table2);
    w_c('<input type="hidden" name="f" value="">');
    w_c('<input type="hidden" name="act" value="">');
    w_c('</form>');
    if (a1 != "" && a2 != "") {
        var host = location.origin;
        var te = "document.f2";
        w_c('<form action="wog_act.php" method="post" target="msn" name="f2">');
        w_c(right_table1);
        w_c('<tr class="head_td"><td colspan="2">推荐好友</td></tr>');
        w_c('<tr><td colspan="2"><input type="text" size="60" onclick="parent.oCopy(this)" value="' + host + '/index.php?recomm=' + Gookie("wog_cookie") + '"><br>您可以复制上面的连结，转发给您的好友注册，透过您的连结注册进来的玩家，每次升级时会您会获得系统奖励回馈</td></tr>');
        w_c(temp_table2);
        w_c('<input type="hidden" name="f" value="">');
        w_c('<input type="hidden" name="act" value="">');
        w_c('<input type="hidden" name="uid" value="' + Gookie("wog_cookie") + '">');
        w_c('<input type="hidden" name="email" value="' + a2 + '">');
        w_c('<input type="hidden" name="pname" value="' + a1 + '">');
        w_c('<input type="hidden" name="qq_password" value="">');
        w_c('</form>');
    }
    w_c('<form action="wog_etc.php" method="get" target="mission" name="f3">');
    w_c('<input type="hidden" name="email" value="">');
    w_c('<input type="hidden" name="f" value="password">');
    w_c('</form>');
    p_c();
};

function oCopy(obj) {
    obj.select();
    js = obj.createTextRange();
    js.execCommand("Copy");
}

//###### event begin ######
function event() {
    var now_time = new Date();
    w_c('<form action="wog_act.php" method="post" target="mission">');
    w_c(temp_table1);
    w_c('<tr><td>站长要考验大家是否有认真在玩</td></tr>');
    w_c('<tr><td colspan="2"><img id="enent_code" src="wog_etc.php?f=confirm&time=' + now_time.getTime() + '"><br><a href=javascript:parent.recode();>看不清楚，重新获取验证码</a></td></tr>');
    w_c('<tr><td>请输入安全验证码:<input type="text" name="sec_code" size="8">(没有数字，不分大小写)</td></tr>');
    w_c('<tr><td colspan="2"><input class="text" type="button" value="填好答案了,放我过关吧!!" onClick="parent.foot_turn(\'event\',\'\',this.form.sec_code.value,\'\')"></td></tr>');
    w_c(temp_table2);
    w_c('</form>');
    p_c();
};

function recode() {
    var now_time = new Date();
    f.getElementById("enent_code").src = 'wog_etc.php?f=confirm&time=' + now_time.getTime();
}

//###### xmas_happy ######
function xmas_happy(s) {
    var temp = '<center>继续努力<br>';
    if (s == 1) {
        temp += '<img border="0" src=http://k53.pbase.com/o5/33/110733/1/69740040.TiqK7YfY.LeeCooperLeeCooper2006_021.jpg>';
    }
    if (s == 2) {
        temp += '<img border="0" src=http://i.pbase.com/o4/33/110733/1/65075517.aljuTijO.chiling_artdeco_018.jpg>';
    }
    if (s == 3) {
        temp += '<img border="0" src=http://k43.pbase.com/o4/33/110733/1/52936435.chiling_129copy.jpg>';
    }
    if (s == 4) {
        temp += '<img border="0" src=http://i.pbase.com/o4/33/110733/1/65075633.1W7My1Cw.chiling_88_023.jpg>';
    }
    temp += '</center>';
    wog_message_box(temp, 0);
};

//###### xmas_money ######
function xmas_money(s) {
    var temp = '<center>';
    temp += '恭喜抽到金钱 ' + s;
    temp += '</center>';
    wog_message_box(temp, 0);
};

//###### xmas_money ######
function xmas_item(s) {
    var temp = '<center>';
    temp += '恭喜抽到 ' + s;
    temp += '</center>';
    wog_message_box(temp, 0);

};

//########## online peo begin ###########
function onlinelist(peo, type) {
    var boy = 0;
    var girl = 0;
    var area_total = 0;
    var temp_s = Gookie("wog_set_onlinelist");
    var temp_t = Gookie("wog_set_online_title");
    var display_status = "";
    switch (type) {
        case 1:
            w_o(online_temp_table1 + '<tr bgcolor="#2B4686"><td colspan="2"><a href=javascript:parent.online_title_show() target="foot">在线名单</a></td></tr>' + temp_table2);
            if (peo != "") {
                display_status = (temp_t == "1") ? "block" : "none";
                w_o('<div id="area_-1" style="display:' + display_status + '">');
                var s1 = peo.split(";");
                for (var temp_p = 0; temp_p < sec.length; temp_p++) {
                    area_total = 0;
                    w_o('<div id="area_' + temp_p + '" style="display:none">');
                    w_o(online_temp_table1 + '<tr bgcolor="#2B4686"><td>名称</td><td>LV</td></tr>');
                    for (var i = 0; i < s1.length; i++) {
                        var s2 = s1[i].split(",");
                        if (temp_p == s2[5]) {
                            var fcolor = psex(s2[1]);
                            (s2[1] == "1") ? boy++ : girl++;
                            (s2[3] == 1) ? s2[3] = "Y" : s2[3] = "N";
                            w_o('<tr bgcolor="#040051"><td ><a href=javascript:parent.yesname("' + s2[0] + '") target="foot" title="PK:' + s2[3] + ',报酬:' + s2[4] + '"><b><font color="' + fcolor + '">' + s2[0] + '</font></b></a></td><td >' + s2[2] + '</td></tr>');
                            area_total++;
                        }
                    }
                    w_o(temp_table2 + '</div>');
                    w_o(online_temp_table1 + '<tr><td  bgcolor="#2B4686" colspan="3">↑<a href=javascript:parent.onlinelist_show("' + temp_p + '") target="foot">' + sec[temp_p][0] + '(' + area_total + ')</a>↑</td></tr>' + temp_table2);
                }
                w_o(online_temp_table1 + '<tr><td  bgcolor="#2B4686" colspan="3"><font color="#66ccff">男生</font> ' + boy + ' 人</td></tr>');
                w_o('<tr><td  bgcolor="#2B4686" colspan="3"><font color="#ff99cc">女生</font> ' + girl + ' 人</td></tr>');
                w_o('<tr><td  bgcolor="#2B4686" colspan="3">线上人数 ' + s1.length + ' 人</td></tr>' + temp_table2);
                w_o('</div>');
            }
            break;
        case 2:
            temp_s = null;
            w_o(online_temp_table1 + '<tr><td colspan="3" bgcolor="#2B4686">线上人数 ' + peo + ' 人</td></tr>' + temp_table2);
            break;
        case 3:
            w_o(online_temp_table1 + '<tr bgcolor="#2B4686"><td colspan="2"><a href=javascript:parent.online_title_show() target="foot">在线名单</a></td></tr>' + temp_table2);
            break;
    }
    p_o();
    Drag.init(f.getElementById("wog_online"));
    if (type == 3) {
        return;
    }
    if (temp_s != null) {
        // onlinelist_show(temp_s);
    }
};

function onlinelist_show(a) {
    var temp_s = Gookie("wog_set_onlinelist");
    for (var temp_p = 0; temp_p < sec.length; temp_p++) {
        f.getElementById("area_" + temp_p).style.display = "none";
    }
    f.getElementById("area_" + a).style.display = "block";
    Sookie("wog_set_onlinelist", a);
};

function online_title_show() {
    var temp_s = Gookie("wog_set_online_title");
    if (temp_s == "1") {
        if (f.getElementById("area_-1")) {
            f.getElementById("area_-1").style.display = "none";
        }
        Sookie("wog_set_online_title", "2");
    } else {
        /*
        var today = new Date();
        if(peo_chk_time+1200000 < today.getTime())
        {
            parent.peolist.document.location="./wog_etc.php?f=peo_cache";
            peo_chk_time=today.getTime();
        }
        */
        if (f.getElementById("area_-1")) {
            f.getElementById("area_-1").style.display = "block";
        }
        Sookie("wog_set_online_title", "1");
    }
};

function psex(s) {
    if (s == "1") {
        return "#66ccff";
    } else {
        return "#ff99cc";
    }
};